<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>while 实现 1 到 100 相加求和</title>
</head>
<body>
<script>
  var a = 1;
  var sum = 0;

  while (a <= 100) {
    sum += a;
    a++;
  }
  alert("1到100之间所有数的和为：" + sum);
</script>
</body>
</html>
